package com.xsf.jieyou.provider.configure;

/**
 * Seata所需数据库代理配置类
 *
 * @author xsf
 * @version v1.0.0
 * @date 2019/12/14 0014 0:54
 * @see com.xsf.jieyou.provider.configure
 **/
//@Configuration
//@EnableConfigurationProperties({MybatisProperties.class})
public class DataSourceProxyConfig {
    /*@Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public HikariDataSource hikariDataSource() {
        return new HikariDataSource();
    }

    @Bean
    @Primary
    public DataSourceProxy dataSourceProxy(HikariDataSource hikariDataSource) {
        return new DataSourceProxy(hikariDataSource);
    }

    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DataSourceProxy dataSourceProxy,
                                                       MybatisProperties mybatisProperties) {
        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
        bean.setDataSource(dataSourceProxy);

        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        try {
            Resource[] mapperLocaltions = resolver.getResources(mybatisProperties.getMapperLocations()[0]);
            bean.setMapperLocations(mapperLocaltions);

            if (StringUtils.isNotBlank(mybatisProperties.getConfigLocation())) {
                Resource[] resources = resolver.getResources(mybatisProperties.getConfigLocation());
                bean.setConfigLocation(resources[0]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bean;
    }*/
}
